<template>
	<view class="header">
		<view class="container">
			<!-- 视频组件 -->
			<view class="video-container" v-if="contentVideoUrl">
				<video 
					:src="contentVideoUrl" 
					:controls="true" 
					:autoplay="false" 
					:loop="false" 
					:show-fullscreen-btn="true" 
					:show-play-btn="true" 
					:show-center-play-btn="true" 
					:enable-progress-gesture="true"
					class="video-player"
				></video>
			</view>
			
			<!-- 内容区域 -->
			<view class="content-container">
				<view class="title"></view>
				<view class="description" v-html="contentText"></view>
				<view v-for="(certificate, index) in swiperList" :key="index" class="certificate">
					<image :src="certificate" class="certificate-image" style="width:100%;height:150px;"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import {
	onLoad,
	onShow
} from '@dcloudio/uni-app'
import {
	ref,
	onMounted
} from 'vue';
import {
	passenger
} from "@/api/index.js"

// 轮播图数据
const swiperList = ref([]);

// 内容文本
const contentText = ref('');

// 视频URL
const contentVideoUrl = ref('');

// 返回上一级页面
const goBack = () => {
	uni.navigateBack({
		delta: 1, // 返回上一级页面
	});
};

onShow(async () => {
	try {
		const res = await passenger.selectAllYiXueYanJiu2();
		if (res.data && res.data.length > 0) {
			const data = res.data[0];
			contentText.value = data.content || '';
			contentVideoUrl.value = data.shipin || '';
			
			// 处理图片数据
			const imagePath = data.imagePath;
			if (imagePath) {
				swiperList.value = imagePath.split(',');
			} else {
				swiperList.value = [];
			}
		}
		console.log('数据加载成功', res.data);
	} catch (error) {
		console.error('数据加载失败', error);
		uni.showToast({
			title: '数据加载失败',
			icon: 'none'
		});
	}
});
</script>

<style scoped>
.container {
	padding: 20rpx;
	position: relative;
}

/* 返回按钮样式 */
.back-button {
	position: absolute;
	top: 20rpx;
	left: 20rpx;
	z-index: 10;
}

.back-text {
	font-size: 32rpx;
	color: #333;
}

.certificate {
	width: 100%;
	margin-bottom: 20rpx;
}

.certificate image {
	width: 100%;
	height: auto;
	border-radius: 10rpx;
}

.swiper-container {
	margin-bottom: 20rpx;
	border-radius: 10rpx;
	overflow: hidden;
}

.swiper {
	height: 300rpx;
}

.swiper-image {
	width: 100%;
	height: 100%;
}

.content-container {
	padding: 20rpx;
	background-color: #fff;
	border-radius: 10rpx;
}

.title {
	font-size: 36rpx;
	font-weight: bold;
	margin-bottom: 20rpx;
}

.description {
	font-size: 28rpx;
	line-height: 1.6;
	color: #666;
	margin-bottom: 20rpx;
}

.section image {
	width: 100%;
}

.history {
	position: relative;
}

.history-bg {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.section-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10px;
}

.section-title {
	font-size: 20px;
	font-weight: bold;
	color: white;
}

.section-arrow {
	color: white;
}

.section-content {
	margin-top: 5px;
}

.section-description {
	font-size: 14px;
	color: white;
	line-height: 1.5;
}

.header {
	position: relative;
	width: 100%;
	height: 180px;
	background: linear-gradient(to bottom, #1c6ddc, #f2f4f7);
	padding-top: 20px;
	z-index: 10;
}

.title {
	color: white;
	font-size: 40rpx;
	font-weight: bold;
	margin-left: 40rpx;
	width: 90%;
	text-align: center;
	line-height: 158rpx;
}

.container {
	padding: 0 20px;
}

.banner {
	margin: 10px 0;
	border-radius: 20px;
	overflow: hidden;
	height: 419rpx;
}

.banner-image {
	width: 100%;
	height: 100%;
}

.section {
	background-color: white;
	border-radius: 20px;
	margin-bottom: 20px;
	padding: 20px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
	overflow: hidden;
	height: 100px;
}

.section-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10px;
}

.section-title {
	font-size: 20px;
	font-weight: bold;
	color: #333;
}

.section-arrow {
	color: #666;
}

.section-content {
	margin-top: 5px;
}

.section-description {
	font-size: 14px;
	color: #666;
	line-height: 1.5;
}

.history {
	background: linear-gradient(to right, #007aff, #00aaff);
	background-image: url("https://aw2025ht.kangye.xyz/api/profile/upload/awsw.jpg");
	color: white;
}

.honor {
	background: linear-gradient(to right, #8B4513, #CD853F);
	color: white;
}

.team {
	background: linear-gradient(to right, #CD853F, #D2B48C);
	color: white;
}

.application {
	background: linear-gradient(to right, #007aff, #00aaff);
	color: white;
}

.section-group {
	display: flex;
	margin-bottom: 20px;
}

.honor {
	flex: 1;
	margin-right: 10px;
}

.section-right {
	display: flex;
	flex-direction: column;
}

.team,
.application {
	flex: 1;
	margin-bottom: 10px;
}

/* 视频组件样式 */
.video-container {
	width: 100%;
	height: 400rpx;
	margin-bottom: 20rpx;
	border-radius: 10rpx;
	overflow: hidden;
	background-color: #000;
}

.video-player {
	width: 100%;
	height: 100%;
}
</style>